package ml.yszhDown.Mobile;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import ml.yszhDown.Mobile.widget.CountDownView;

public class StartPage extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_start_page);

        final CountDownView cdv=findViewById(R.id.myCountDown);
        cdv.setAddCountDownListener(new CountDownView.OnCountDownFinishListener() {
            @Override
            public void countDownFinished() {
                startMainActivity();
            }
        });
        cdv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cdv.endCountDown();
            }
        });
        cdv.startCountDown();;



    }

    private void startMainActivity(){
        Intent it=new Intent(getApplicationContext(),MainActivity.class);
        startActivity(it);
        finish();
    }

    @Override
    protected void onStop() {
        super.onStop();
        final CountDownView cdv=findViewById(R.id.myCountDown);
        cdv.endCountDown();
    }
}
